{% extends './layout.html'%} {%block main%}
<style>
	h6 {
		margin-bottom: 5px;
	}
	i.qrcode{
		cursor: pointer;
	}
	#qrcode{
		text-align: center;
		padding : 20px 40px;
		display: none;
	}
	#qrcode p{
		padding-top:30px;
	}
    #pager{
        text-align: center;
    }
</style>
<blockquote class="layui-elem-quote news_search layui-form">
	<form action="">
	<input type=hidden name=page value='{{page}}'>
	<div class="layui-inline">
		<div class="layui-input-inline">
			<h6>手机号</h6>
			<input type="text" name=phone value="{{phone}}" placeholder="手机号" class="layui-input search_input">
		</div>

	</div>
    <div class="layui-inline">
		<div class="layui-input-inline">
			<h6>昵称</h6>
			<input type="text" name=nickname value="{{nickname}}" placeholder="昵称" class="layui-input search_input">
		</div>

	</div>

	
	<div class="layui-inline" style=''>
		<h6>&nbsp;</h6>
		<a class="layui-btn layui-btn-normal" onclick='$("form").submit()'>查询</a>

	</div>
	</form>
	<!--<div class="layui-input-inline">
			<input type="text" value="" placeholder="开始时间" class="layui-input search_input">
		</div>
		<div class="layui-input-inline">
			<input type="text" value="" placeholder="结束时间" class="layui-input search_input">
		</div>
		<div class="layui-input-inline">
			<input type="text" value="" placeholder="所属单位" class="layui-input search_input">
		</div>
		<a class="layui-btn search_btn">查询</a>-->
</blockquote>

<div class="layui-form news_list">
	<table class="layui-table">

		<thead>
			<tr>
				<th style="text-align:left;">
					序号</th>
				<th>客户手机号</th>
				<th>客户昵称</th>

                <th>上级</th>
				<th>当日交易额</th>
				<th>当日胜率</th>
				<th>总胜率</th>
				<th>操作</th>
			</tr>
		</thead>

		<tbody class="news_content">
			{%for item in list%}
			<tr>
				<td>{{loop.index + (page - 1) * 20}}</td>
				<td>{{item.phone}}</td>
				<td>

					{{item.nickname}}
				</td>

				<td>
					{{'【综合会员】' if item.parent.type == 'normal'}}
					{{'【经纪会员】' if item.parent.type == 'jingji'}}
					{{'【机构代理】' if item.parent.type == 'jigou'}}
					{{'【居间代理】' if item.parent.type == 'jujian'}}
					{{item.parent.nickname}}
				</td>
				<td>
					{{item.mm if item.mm else 0}}
				</td>
				<td>
					{{item.day_rate}}%
				</td>
				<td>
					{{item.total_rate}}%
				</td>
				
				<td style="position: relative;">
					<select class="action" lay-verify="" lay-filter='action' data-id='{{item.id}}' data-phone='{{item.phone}}'>
						<option value="">操作</option>
						<option value="detail">客户交易明细</option>
						<!--<option value="login_pass">重置登录密码</option>
						<option value="pay_pass">重置资金密码</option>
						<option value="zhuanyi">转移</option>
						<option value="jigou_child">下属机构代理</option>
						<option value="jujian_child">下属居间代理</option>-->
					</select>

				</td>

			</tr>
			{%endfor%}
		</tbody>
	</table>
</div>

<div id='pager'>

</div>

{%endblock%} {%block js%}
<script src='/static/js/qrcode.js'></script>
<script>
	layui.use(["laydate", "element", "form","laypage"], function(laydate, ele, form,laypage) {
		//执行一个laydate实例
		laydate.render({
			elem: '#start_time' //指定元素
		});

		laydate.render({
			elem: '#end_time' //指定元素
		});
		
		laypage.render({
			elem: 'pager',
			count: '{{count}}' ,//数据总数，从服务端得到
			limit:20	,
            curr :'{{page}}',
			jump: function(obj, first) {
				//obj包含了当前分页的所有参数，比如：
				console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
				console.log(obj.limit); //得到每页显示的条数

				//首次不执行
				if(!first) {
					$('input[name=page]').val(obj.curr);
					$("form").submit();
					//do something
				}
			}
		});


		form.on("select(action)", function(data) {
			var val = data.value;
			if(val == '') {
				return;
			}
			var id = $(data.elem).attr('data-id');
			var phone = $(data.elem).attr('data-phone');
			switch(val) {
				case 'detail':
					parent.$(".layui-nav-item a[data-url='/proxy/order_list.html']").trigger('click','?phone=' + phone)
//					openWindow("编辑", "/proxy/addMember.html?id=" + id)
					break;
					
				
			}
			$(data.othis).parent().find("[lay-value='']").trigger('click');
			//			alert(1)
		});
	});

	function openWindow(title, href) {
		var index = layui.layer.open({
			title: title,
			type: 2,
			content: href,
			success: function(layero, index) {
				setTimeout(function() {
					//layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
					//	tips: 3
					//});

					var iframe = $('iframe');
					var body = $(iframe.contents()).find("body");
					iframe.height($(window).height() - 100)
				}, 100);
			}
		})

		layui.layer.full(index);
	}

	$(function() {

		
		$('.qrcode').click(function(){
			var id = $(this).attr('data-id');

			var url = "http://www.baidu.com/s" + id
			$('#qrcode > div').html("").qrcode({
				width: 200,
				height:200,
				text: url
			});
			
			$('#qrcode > p').html(url);

			layui.layer.open({
				type : 1,
				content : $('#qrcode'),
				title : "推广二维码"
			});
		});

		$(window).one("resize", function() {
			$('.addJingji').click(function() {
				openWindow("添加", "/proxy/addMember.html?");
			});
		}).resize();
	})
</script>
{%endblock%}